﻿using G.Service.BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace G.Service.Service
{
    /// <summary>
    /// APITestService 的摘要说明
    /// </summary>
    public class APITestService : BaseHandler
    {
        protected override void ProcessRequest(HttpContext context, out BLL.IResult result, string action)
        {
            switch (action)
            {
                case "updateapitestconfig":
                    if (context.Request.HttpMethod.ToLower() == "post")
                    {
                        string userid = QueryString["userid"];
                        string projectname = QueryString["projectname"];
                        string projectconfig = QueryString["projectconfig"];
                        result = BLL.APPTestProjectBLL.UpdateProjectConfig(int.Parse(userid), projectname, projectconfig);
                    }
                    else
                        result = new Result() { Msg = "请使用Post方法" };
                    break;
                case "addapitestproject":
                    if (context.Request.HttpMethod.ToLower() == "post")
                    {
                        string userid = QueryString["userid"];
                        string projectname = QueryString["projectname"];
                        string projectconfig = QueryString["projectconfig"];
                        result = BLL.APPTestProjectBLL.AddAPPTestProject(int.Parse(userid), projectname, projectconfig);
                    }
                    else
                        result = new Result() { Msg = "请使用Post方法" };
                    break;
                case "getapitestprojectlist":
                    {
                        string userid = QueryString["userid"];
                        result = BLL.APPTestProjectBLL.GetAllAPITestProjectsByUserId(int.Parse(userid));
                    }
                    break;
                default:
                    result = new BLL.Result() { Msg = "指定的action无效！" };
                    break;
            }
        }
    }
}